package com.swgk.core.common.base;

import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.ViewModelProvider;

import com.swgk.core.dialog.DialogHelper;
import com.swgk.core.interfaces.IView;

/**
 * @author : younghow
 * @date : 2021/10/18 11:30
 * description:
 */
public abstract class TeamBaseActivity<VM extends TeamViewModel<IView>, DB extends ViewDataBinding> extends BaseActivity<VM,DB> implements IView {


    @Override
    protected void init() {
        initView();
        initData();
    }

    @Override
    protected void createViewModel() {
        mViewModel = new ViewModelProvider(this).get(createVM());
        mViewModel.setView(this);
    }

    protected abstract Class<VM> createVM();
    protected abstract void initView();
    protected abstract void initData();

    @Override
    public void loading() {
        DialogHelper.showProgressDialog(this, null, "数据加载中...", 0, false, null);
    }

    @Override
    public void success() {
        DialogHelper.dismissProgressDialog();
    }

    @Override
    public void fail() {
        DialogHelper.dismissProgressDialog();
    }
}
